``` swift
extension UIResponder {
    
    static func firstResponder() -> AnyObject? {
        currentFirstResponder = nil
        // 通过将target设置为nil，让系统自动遍历响应链
        // 从而响应链当前第一响应者响应我们自定义的方法        
        UIApplication.shared.sendAction(#selector(findFirstResponder(_:)), to: nil, from: nil, for: nil)
        return currentFirstResponder
    }
    @objc func findFirstResponder(_ sender: AnyObject) {
        // 第一响应者会响应这个方法，并且将静态变量wty_currentFirstResponder设置为自己
        currentFirstResponder = self
    }
}

```

``` 使用
if let strongSelf = self {
                if let currTF = UIResponder.firstResponder() as? UITextField {
                    let realFrame = strongSelf.view.convert(currTF.frame, from: currTF.superview)
                    let offset = realFrame.origin.y + realFrame.size.height + keyboardHeight - strongSelf.view.bounds.height
                    if offset > 0 {
                        strongSelf.view.frame.origin.y = -offset
                    }
                }
                strongSelf.view.layoutIfNeeded()
            }
```